﻿using Delimon.Win32.IO;
using System;

namespace rmlpathdir
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                try
                {
                    Deletedir(new DirectoryInfo(args[0]));
                    Console.WriteLine("删除成功！按任意键退出！");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            else {
                Console.WriteLine("未指定要删除的文件夹路径！");
            }

            Console.ReadKey();
        }

        public static void Deletedir(DirectoryInfo Dir)
        {
            if (!Dir.Exists)
            {
                Console.WriteLine("文件夹路径不存在！需输入文件夹完整路径。");
                return;
            }

            foreach (var dir in Dir.GetDirectories())
            {
                Console.WriteLine(dir);

                Deletedir(dir);
            }

            Dir.Delete(true);
        }
    }
}
